package main

import (
	"flag"
	"fmt"
	"google.golang.org/grpc"
	"log"
	"net"
	"zg5/videos/common/inits"
	"zg5/videos/common/proto/videos"
	"zg5/videos/video-server/handler"
)

func main() {

	inits.GetViper()
	inits.InitNacos()
	inits.InitMysql()
	InitGrpc()
}

func InitGrpc() {
	flag.Parse()
	lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 8880))
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	videos.RegisterVideoSrvServer(s, &handler.Server{})
	log.Printf("server listening at %v", lis.Addr())
	if err = s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
